package com.niit.dao.impl;

import com.niit.dao.IClassificationDao;
import com.niit.domain.Classification;
import com.niit.utils.DBHelper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class ClassificationDaoImpl implements IClassificationDao {
    @Override
    public List<Classification> queryClassification() {
        List<Classification> list=new ArrayList<>();
        String sql="select * from sh_classification";
        ResultSet rs= DBHelper.executeQuery(sql);
        Classification classification=null;
        while(true){
            try {
                if (!rs.next()) break;
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                classification=new Classification(rs.getInt(1),rs.getString(2),rs.getInt(3));
            } catch (SQLException e) {
                e.printStackTrace();
            }
            list.add(classification);
        }
        return list;
    }
}
